<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript" src="https://static.iyunbao.com/website/health/iybApp/lib/JSBridge/JSBridge-1.0.2.min.js"></script>
<script type="text/javascript" src="https://cdn-qcloud.zhongan.com/a00000/Project/HealthInsurance/iYunBao/js/common/wechatdemo.js?v=201606161609"></script>
<script type="text/javascript" src="../js/comm.pickerStack.js?v=20180518001"></script>
<script type="text/javascript" src="../js/echarts/echarts.min.4.1.0.rc2.blp.js"></script>
<script src="//static.iyunbao.com/website/health/iybApp/lib/mylog/1.0/mylog-1.0.0.min.js"></script>

<style>
    .form .alert
    {
        height: auto;
    }
</style>

<script>
    var isReady = false;
    $(document).ready( function() {
        common.req('util/wxconfig.json', {platformId: 2, url: encodeURIComponent(location.href)}, function(r){
            var result = r.result;
            wx.config({
                debug: false,
                appId: result.appId,
                timestamp: result.timestamp,
                nonceStr: result.nonceStr,
                signature: result.signature,
                jsApiList: [
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    "onMenuShareQQ",
                    "onMenuShareWeibo",
                    "onMenuShareQZone"
                ],
                fail: function(res){
                    alert(JSON.stringify(res));
                }
            });
            wx.ready(function(){
                isReady = true;
            });
        }, function(r){});
    });
    var setEnd = true;
    var wxReady = function(shareObj, shareCallback){
        if(!setEnd) {
            setTimeout(function(){
                wxReady(shareObj, shareCallback);
            }, 100);
        } else {
            wxSet(shareObj, function(wx){
                wx.onMenuShareTimeline({
                    title  : shareObj.title || "投保成功",
                    desc   : shareObj.desc || '投保成功',
                    imgUrl : shareObj.imgUrl,
                    link   : shareObj.link,
                    success: shareCallback,
                    cancel: function(){
                        console.log('分享取消了');
                    }
                });
                wx.onMenuShareAppMessage({
                    title  : shareObj.title || "投保成功",
                    desc   : shareObj.desc || '投保成功',
                    imgUrl : shareObj.imgUrl,
                    link   : shareObj.link,
                    success: shareCallback,
                    cancel: function(){
                        console.log('分享取消了');
                    }
                });
                wx.onMenuShareQQ({
                    title  : shareObj.title || "投保成功",
                    desc   : shareObj.desc || '投保成功',
                    imgUrl : shareObj.imgUrl,
                    link   : shareObj.link,
                    success: shareCallback,
                    cancel: function(){
                        console.log('分享取消了');
                    }
                });
                wx.onMenuShareWeibo({
                    title  : shareObj.title || "投保成功",
                    desc   : shareObj.desc || '投保成功',
                    imgUrl : shareObj.imgUrl,
                    link   : shareObj.link,
                    success: shareCallback,
                    cancel: function(){
                        console.log('分享取消了');
                    }
                });
                wx.onMenuShareQZone({
                    title  : shareObj.title || "投保成功",
                    desc   : shareObj.desc || '投保成功',
                    imgUrl : shareObj.imgUrl,
                    link   : shareObj.link,
                    success: shareCallback,
                    cancel: function(){
                        console.log('分享取消了');
                    }
                });
            });
        }
    };


    var wxSet = function(shareObj, func){
        setEnd = false;
        setTimeout(function(){
            if (isReady) {
                if(func) func(wx);
                setEnd = true;
            } else {
                wxSet(shareObj, func)
            }
        }, 100);
    };

</script>
<script>
    (function() {
        var mylog = document.createElement("script");
        mylog.src = "//static.iyunbao.com/website/health/iybApp/lib/mylog/1.0/mylog-1.0.0.min.js";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(mylog, s);
    })();
</script>
